import java.io.*;
import java.net.*;

public class FileDetails implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 6359671491991130135L;
	public String name;
	public long hash;
	public long size;
	public long lastModified;
	public InetAddress fileOwner;
	
	public FileDetails(String n, long h, long s, long lM, InetAddress ip) {
		name = n;
		hash = h;
		size = s;
		lastModified = lM;
		fileOwner = ip;
	}
	
	public String getName(){
		return name;
	}
	public String getHash(){
		return Long.toString(hash);
	}
	public String getSize(){
		return Long.toString(size);
	}
	public String getLastModified(){
		return Long.toString(lastModified);
	}
	public String getFileOwner(){
		return fileOwner.toString();
	}
	public long getHashLong(){
		return hash;
	}
	public boolean equals(Object theOther) {
		if(hash == ((FileDetails) theOther).getHashLong()) {
			return true;
		}
		return false;
	}

	
	//User Adler32 hash here?
	public int hashCode() 
	{
		File file = new File(name);

		long fileSize = file.length();
//		if (fileSize != size)
//		{
//			System.out.println("The file size is wrong.  Also, someone should make a better exception ;p");
//			try
//			{
//				throw new Exception();
//			} catch (Exception e)
//			{
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
//
//		}
		byte[] bytesArray = new byte[(int) fileSize];
		return (int) GUI1.myProject.adlerHash(bytesArray);
		// FileDetails
		
	}
	
	public String toString() {
		return name;
	}

}
